home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
PROBLEMS
/
BENCHMARK
/
BUBBLESORT
/
bubbletest
/
gawk_l
/
source
< prev
next >
Wrap
Text File
|
1992-05-13
|
660b
|
37 lines
function bubblesort(a,len \
,flag,count,temp)
{
flag=1;
while (flag)
{
flag=0;
for (count=0;count<len-1;count=count+1)
if (a[count]>a[count+1])
{
temp=a[count]
a[count]=a[count+1]
a[count+1]=temp
flag=1;
}
}
}
BEGIN {
# pseudo ramdom
pseudoramdom=123456;
for (count=0;count<1000;count=count+1)
{
pseudoramdom=(pseudoramdom + 234567) % 567 + 345
a[count]=pseudoramdom;
print(a[count])
}
system("time")
bubblesort(a,1000)
system("time")
for (count=0;count<1000;count=count+1)
print(a[count])
}